<template>
  <div class="da">
    <div class="xiao">
      <div class="img"></div>
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleFormref"
        class="demo-ruleForm"
      >
        <el-form-item prop="username">
          <el-input
            v-model="ruleForm.username"
            prefix-icon="iconfont icon-yonghuming"
          ></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            v-model="ruleForm.password"
            show-password
            prefix-icon="iconfont icon-mima"
          ></el-input>
        </el-form-item>
        <el-form-item style="text-align: right">
          <el-button type="primary" @click="submitForm">登录</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { LjhLogin } from "@/http/api";
export default {
  data() {
    return {
      ruleForm: {
        username: "admin",
        password: "123456",
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 3, max: 6, message: "长度在 3 到 6 个字符", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.ruleFormref.validate((valid) => {
        if (valid) {
          LjhLogin(this.ruleForm).then((res) => {
            console.log(res);
          });
        } else {
          return false;
        }
      });
    },
  },
  mounted() {},

  computed: {},

  watch: {
    cart: {
      handler(newValue) {},
      deep: true,

      immediate: true,
    },
  },
};
</script>

<style scoped lang="scss">
.da {
  width: 100%;
  height: 100%;
  background: url("../../assets//img/1.png");
  background-size: 100%;
  position: relative;
  .xiao {
    height: 300px;
    width: 600px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    border-radius: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.4);
    .img {
      position: absolute;
      top: -50px;
      left: 42%;
      width: 100px;
      height: 100px;
      border-radius: 50px;
      background: url("../../assets//img/3.png");
      background-size: 100%;
    }
    .el-form {
      width: 70%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      margin:170px auto;
     
    }
  }
}
</style>
